package org.panda.tcmoc.domain;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.sql.Time;
import java.util.Date;

import org.panda.tcmoc.config.Configure;

public class SpProduct extends ModelObject implements PropertyChangeListener {
	@Override
	public String toString() {
		return "SpProduct [dealTicketNo=" + dealTicketNo + ", cnyAmount="
				+ cnyAmount + ", pkSeqNo=" + pkSeqNo + ", branchNo=" + branchNo
				+ ", gtdNo=" + gtdNo + ", productName=" + productName
				+ ", productCode=" + productCode + ", ccy=" + ccy
				+ ", nomialPrinAc=" + nomialPrinAc + ", acType=" + acType
				+ ", counterPartyName=" + counterPartyName
				+ ", counterPartyType=" + counterPartyType
				+ ", counterPartyCode=" + counterPartyCode + ", operationType="
				+ operationType + ", agreementType=" + agreementType
				+ ", beginDate=" + beginDate + ", endDate=" + endDate
				+ ", txnType=" + txnType + ", version=" + version
				+ ", subVersion=" + subVersion + ", status=" + status
				+ ", makerId=" + makerId + ", checkId=" + checkId + "]";
	}

	private String dealTicketNo;
	private Double cnyAmount;
	private String pkSeqNo;
	private String branchNo;
	private String gtdNo;
	private String productName;

	private String productCode;
	private String ccy;
	private Double nomialPrinAc;
	private String acType;
	private String counterPartyName;
	private String counterPartyType;
	private String counterPartyCode;
	private String operationType;
	private String agreementType;
	private Date beginDate;
	private Date endDate;
	private String txnType;

	private Integer version;
	private Integer subVersion;

	private String status;
	private String makerId;
	private String checkId;
	private Date makerTime;
	private Date checkerTime;
	
	public static String STATUS_CREATE = "CREATE";
	public static String STATUS_ACTIVE = "ACTIVE";
	public static String STATUS_INACTIVE = "INACTIVE";
	public static String STATUS_MODIFY = "MODIFY";
	public static String STATUS_DELETE = "DELETE";
	public static String STATUS_REPAIR = "REPAIR";

	public boolean isEmpty() {
		if (this.dealTicketNo == "" || this.dealTicketNo == null) {
			return true;
		} else {
			return false;
		}
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Integer getSubVersion() {
		return subVersion;
	}

	public void setSubVersion(Integer subVersion) {
		this.subVersion = subVersion;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getMakerId() {
		return makerId;
	}

	public void setMakerId(String makerId) {
		this.makerId = makerId;
	}

	public String getCheckId() {
		return checkId;
	}

	public void setCheckId(String checkId) {
		this.checkId = checkId;
	}

	public Date getMakerTime() {
		return makerTime;
	}

	public void setMakerTime(Date makerDate) {
		this.makerTime = makerDate;
	}

	public Date getCheckerTime() {
		return checkerTime;
	}

	public void setCheckerTime(Date checkerDate) {
		this.checkerTime = checkerDate;
	}

	@SuppressWarnings("deprecation")
	public SpProduct() {
		/**
		 * setup default value
		 */
		this.operationType = Configure.OPERATION_TYPE_ARRAY[0];
		this.agreementType = Configure.AGREEMENT_TYPE_ARRAY[0];
		this.ccy = Configure.CURRENCY_ARRAY[0];
		this.acType = Configure.ACCOUNT_TYPE_ARRAY[0];
		this.counterPartyType = Configure.COUNTER_PARTY_TYPE_ARRAY[0];
		this.txnType = Configure.TXN_TYPE_ARRAY[0];

		this.cnyAmount = Double.valueOf(0);
		this.nomialPrinAc = Double.valueOf(0);
		this.beginDate = new Date();
		this.endDate = new Date();
		this.version = 1;
		this.subVersion = 1;

		this.makerTime = new Date(0);
		this.checkerTime = new Date(0);
	}

	public String getDealTicketNo() {
		return dealTicketNo;
	}

	public void setDealTicketNo(String dealTicketNo) {
		this.getChangeSupport().firePropertyChange("dealTicketNo",
				this.dealTicketNo, this.dealTicketNo = dealTicketNo);
	}

	public Double getCnyAmount() {
		return cnyAmount;
	}

	public void setCnyAmount(Double amount) {
		this.getChangeSupport().firePropertyChange("cnyAmount", this.cnyAmount,
				this.cnyAmount = amount);
	}

	public String getPkSeqNo() {
		return pkSeqNo;
	}

	public void setPkSeqNo(String pkSeqNo) {
		this.pkSeqNo = pkSeqNo;
	}

	public String getBranchNo() {
		return branchNo;
	}

	public void setBranchNo(String branchNo) {
		String oldValue = this.branchNo;
		this.branchNo = branchNo;
		this.getChangeSupport().firePropertyChange("branchNo", oldValue,
				branchNo);

	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getGtdNo() {
		return gtdNo;
	}

	public void setGtdNo(String gtdNo) {
		this.gtdNo = gtdNo;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {

		this.productCode = productCode;
	}

	public String getCcy() {
		return ccy;
	}

	public void setCcy(String ccy) {
		this.getChangeSupport().firePropertyChange("ccy", this.ccy,
				this.ccy = ccy);
	}

	public Double getNomialPrinAc() {
		return nomialPrinAc;
	}

	public void setNomialPrinAc(Double nomialPrinAc) {
		this.nomialPrinAc = nomialPrinAc;
	}

	public String getAcType() {
		return acType;
	}

	public void setAcType(String acType) {
		this.getChangeSupport().firePropertyChange("acType", this.acType,
				this.acType = acType);
	}

	public String getCounterPartyName() {
		return counterPartyName;
	}

	public void setCounterPartyName(String counterPartyName) {
		this.counterPartyName = counterPartyName;
	}

	public String getCounterPartyType() {
		return counterPartyType;
	}

	public void setCounterPartyType(String counterPartyType) {
		this.counterPartyType = counterPartyType;
	}

	public String getCounterPartyCode() {
		return counterPartyCode;
	}

	public void setCounterPartyCode(String counterPartyCode) {
		this.counterPartyCode = counterPartyCode;
	}

	public String getOperationType() {
		return operationType;
	}

	public void setOperationType(String operationType) {
		this.operationType = operationType;
	}

	public String getAgreementType() {
		return agreementType;
	}

	public void setAgreementType(String agreementType) {
		this.agreementType = agreementType;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getTxnType() {
		return txnType;
	}

	public void setTxnType(String txnType) {
		this.txnType = txnType;
	}

	public void propertyChange(PropertyChangeEvent evt) {
		// this.getChangeSupport().firePropertyChange("acType", null, acType);
	}

}
